package com.lms.netty.codec;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.CharsetUtil;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-06-16 10:36
 * @Description:
 */
public class NettyClientHandler  extends SimpleChannelInboundHandler<Long> {
    /**
    * @Author 李孟帅
    * @Description 当通道就绪就会触发该方法
    * @Date 2020/6/16
    **/
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        System.out.println("客户端发送数据");
        ctx.writeAndFlush(123456L);//直接发送一个long

    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
       cause.printStackTrace();
       ctx.close();
    }


    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Long aLong) throws Exception {

    }
}
